﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Superstore.Vender.App_Code
{
    public class WXInfoCacheMgr
    {
        private static string GPS_LAT_SUF = "Latitude";
        private static string GPS_LOG_SUF = "Longitude";
        private static int GPS_TIMES_INTERVAl = 10000;//保险起见

        public static void SetLatitude(double latitude, string openId)
        {
            string latKey = openId + GPS_LAT_SUF;
            CommonCacheHelper.SetCache(latKey, latitude, DateTime.MaxValue, TimeSpan.FromSeconds(GPS_TIMES_INTERVAl));
        }

        public static double GetLatitude(string openId)
        {
            string latKey = openId + GPS_LAT_SUF;
            return Convert.ToDouble(CommonCacheHelper.GetCache(latKey));
        }

        public static void SetLongitude(double longitude, string openId)
        {
            string logKey = openId + GPS_LOG_SUF;
            CommonCacheHelper.SetCache(logKey, longitude, DateTime.MaxValue, TimeSpan.FromSeconds(GPS_TIMES_INTERVAl));
        }

        public static double GetLongitude(string openId)
        {
            string logKey = openId + GPS_LOG_SUF;
            return Convert.ToDouble(CommonCacheHelper.GetCache(logKey));
        }

        public static void ClearCatch(string openId)
        {
            string Key = openId + GPS_LOG_SUF;
            CommonCacheHelper.RemoveKeyCache(Key);
            Key = openId + GPS_LAT_SUF;
            CommonCacheHelper.RemoveKeyCache(Key);
        }
    }
}